package com.example.framework.mqtt.core.client;

import com.example.framework.mqtt.core.exception.MqttMessageException;
import com.example.framework.mqtt.core.model.MqttModel;
import net.dreamlu.iot.mqtt.codec.MqttQoS;
import net.dreamlu.iot.mqtt.core.client.IMqttClientMessageListener;
import net.dreamlu.iot.mqtt.core.client.MqttClientSubscription;

import java.util.List;

public interface MqttPlatformClient {

    /**
     * publish message
     */
    void publish(MqttModel<?> mqttModel) throws MqttMessageException;

    /**
     * publish message with response topic
     */
    void publishWithResponseTopic(String responseTopic, MqttModel<?> mqttModel) throws MqttMessageException;

    /**
     * subscribe topic with qos 0
     *
     * @param topic
     * @param messageListener
     * @throws MqttMessageException
     */
    void subscribeQos0(String topic, IMqttClientMessageListener messageListener) throws MqttMessageException;

    /**
     * subscribe topic with qos 0
     *
     * @param topic
     * @param messageListener
     * @throws MqttMessageException
     */
    void subscribeQos1(String topic, IMqttClientMessageListener messageListener) throws MqttMessageException;

    /**
     * subscribe topic with qos 0
     *
     * @param topic
     * @param messageListener
     * @throws MqttMessageException
     */
    void subscribeQos2(String topic, IMqttClientMessageListener messageListener) throws MqttMessageException;

    /**
     * subscribe topic
     *
     * @param topic
     * @param qos
     * @param messageListener
     * @throws MqttMessageException
     */
    void subscribe(String topic, MqttQoS qos, IMqttClientMessageListener messageListener) throws MqttMessageException;

    /**
     * subscribe topic
     *
     * @param mqttListenerList
     */
    void subscribe(List<MqttClientSubscription> mqttListenerList);

    /**
     * unsubscribe topic1
     *
     * @param topic
     * @throws MqttMessageException
     */
    void unsubscribe(String topic) throws MqttMessageException;

    /**
     * disconnect
     */
    void disconnect();

    /**
     * reconnect
     */
    void reconnect();
}
